import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '货品名称',
    align: "center",
    dataIndex: 'goodsName',
    resizable: true,
    width: 400,
  },
  {
    title: '货品条码',
    align: "center",
    dataIndex: 'goodsNo'
  },
  {
    title: '规格名称',
    align: "center",
    dataIndex: 'specName'
  },
  {
    title: '批次',
    align: "center",
    dataIndex: 'batchNo'
  },
  {
    title: '生产日期',
    align: "center",
    dataIndex: 'productionDate',
    customRender: ({ text }) => {
      text = !text ? "" : (text.length > 10 ? text.substr(0, 10) : text);
      return text;
    },
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'gmtCreate',
    sorter: true,
  },
  {
    title: '是否抽检',
    align: "center",
    dataIndex: 'checked_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "货品条码",
    field: 'goodsNo',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "创建时间",
    field: "gmtCreate",
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
      // showTime:true
    },
    //colProps: {span: 6},
  },
  {
    label: "是否抽检",
    field: 'checked',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "yn",
      stringToNumber: true,
    },
    //colProps: {span: 6},
  },
  {
    label: "生产日期",
    field: "productionDate",
    component: 'RangePicker',
    componentProps: {
      valueType: 'Date',
    },
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '货品名称',
    field: 'goodsName',
    component: 'Input',
  },
  {
    label: '货品条码',
    field: 'goodsNo',
    component: 'Input',
  },
  {
    label: '规格名称',
    field: 'specName',
    component: 'Input',
  },
  {
    label: '批次',
    field: 'batchNo',
    component: 'Input',
  },
  {
    label: '生产日期',
    field: 'productionDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '创建日期',
    field: 'gmtCreate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '是否抽检',
    field: 'checked',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "yn",
      type: 'radio',
      stringToNumber: true,
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  goodsName: { title: '货品名称', order: 0, view: 'text', type: 'string', },
  goodsNo: { title: '货品条码', order: 1, view: 'text', type: 'string', },
  specName: { title: '规格名称', order: 2, view: 'text', type: 'string', },
  batchNo: { title: '批次', order: 3, view: 'text', type: 'string', },
  productionDate: { title: '生产日期', order: 4, view: 'date', type: 'string', },
  checked: { title: '是否抽检', order: 5, view: 'number', type: 'number', dictCode: 'yn', },
  gmtCreate: { title: '创建时间', order: 0, view: 'datetime', type: 'string', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}